/*
 * @lc app=leetcode.cn id=2482 lang=cpp
 *
 * [2482] 行和列中一和零的差值
 */
#include<vector>
using namespace std;
// @lc code=start
class Solution {
public:
    vector<vector<int>> onesMinusZeros(vector<vector<int>>& grid) {
        int m =grid.size();
        int n=grid[0].size();
        vector<int> temArr1= vector<int>(m,0);
        vector<int> temArr2= vector<int>(n,0);
        for( int i =0;i<m;i++){
            for (int j=0;j<n;j++){
                if (grid[i][j]==0){
                    --temArr1[i];
                    --temArr2[j];
                }else{
                    ++temArr1[i];
                    ++temArr2[j];    
                }
            }
        }
        for( int i =0;i<m;i++){
            for (int j=0;j<n;j++){
                grid[i][j]=temArr1[i]+temArr2[j];
            }
        }
        return grid;
    }
};
// @lc code=end

